home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
IRIX Base Documentation 1998 November
/
IRIX 6.5.2 Base Documentation November 1998.img
/
usr
/
share
/
catman
/
u_man
/
cat3
/
Tcl
/
tildesubst.z
/
tildesubst
Wrap
Text File
|
1998-10-30
|
5KB
|
133 lines
TTTTccccllll____TTTTiiiillllddddeeeeSSSSuuuubbbbsssstttt((((3333TTTTccccllll)))) TTTTccccllll____TTTTiiiillllddddeeeeSSSSuuuubbbbsssstttt((((3333TTTTccccllll))))
NNNNAAAAMMMMEEEE
Tcl_TildeSubst - replace tilde with home directory in a file name
SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
####iiiinnnncccclllluuuuddddeeee <<<<ttttccccllll....hhhh>>>>
char *
TTTTccccllll____TTTTiiiillllddddeeeeSSSSuuuubbbbsssstttt(_i_n_t_e_r_p, _n_a_m_e, _b_u_f_f_e_r_P_t_r) |
AAAARRRRGGGGUUUUMMMMEEEENNNNTTTTSSSS
Tcl_Interp *_i_n_t_e_r_p (in) Interpreter in which to report an
error, if any.
char *_n_a_m_e (in) File name, which may start with a
``~''.
Tcl_DString *_b_u_f_f_e_r_P_t_r If needed, this dynamic string is |
used to store the new file name. At|
the time of the call it should be |
uninitialized or empty. The caller |
must eventually call TTTTccccllll____DDDDSSSSttttrrrriiiinnnnggggFFFFrrrreeeeeeee|
to free up anything stored here.
DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
This utility procedure does tilde substitution. If _n_a_m_e doesn't start
with a ``~'' character, then the procedure returns _n_a_m_e. If _n_a_m_e does
start with a tilde, then TTTTccccllll____TTTTiiiillllddddeeeeSSSSuuuubbbbsssstttt returns a new string identical to
_n_a_m_e except that the first element of _n_a_m_e is replaced with the location
of the home directory for the given user. The substitution is carried
out in the same way that it would be done by _c_s_h. If the tilde is
followed immediately by a slash, then the $$$$HHHHOOOOMMMMEEEE environment variable is
substituted. Otherwise the characters between the tilde and the next
slash are taken as a user name, which is looked up in the password file;
the user's home directory is retrieved from the password file and
substituted.
If TTTTccccllll____TTTTiiiillllddddeeeeSSSSuuuubbbbsssstttt has to do tilde substitution then it uses the dynamic |
string at *_b_u_f_f_e_r_P_t_r to hold the new string it generates. After |
TTTTccccllll____TTTTiiiillllddddeeeeSSSSuuuubbbbsssstttt returns a non-NULL result, the caller must eventually |
invoke TTTTccccllll____DDDDSSSSttttrrrriiiinnnnggggFFFFrrrreeeeeeee to free up any information placed in *_b_u_f_f_e_r_P_t_r. |
The caller need not know whether or not TTTTccccllll____TTTTiiiillllddddeeeeSSSSuuuubbbbsssstttt actually used the |
string; TTTTccccllll____TTTTiiiillllddddeeeeSSSSuuuubbbbsssstttt initializes *_b_u_f_f_e_r_P_t_r even if it doesn't use it,|
so the call to TTTTccccllll____DDDDSSSSttttrrrriiiinnnnggggFFFFrrrreeeeeeee will be safe in either case.
If an error occurs (e.g. because there was no user by the given name)
then NULL is returned and an error message will be left at _i_n_t_e_r_p-
>_r_e_s_u_l_t. When an error occurs, TTTTccccllll____TTTTiiiillllddddeeeeSSSSuuuubbbbsssstttt frees the dynamic string |
itself so that the caller need not call TTTTccccllll____DDDDSSSSttttrrrriiiinnnnggggFFFFrrrreeeeeeee.
PPPPaaaaggggeeee 1111
TTTTccccllll____TTTTiiiillllddddeeeeSSSSuuuubbbbsssstttt((((3333TTTTccccllll)))) TTTTccccllll____TTTTiiiillllddddeeeeSSSSuuuubbbbsssstttt((((3333TTTTccccllll))))
The caller is responsible for making sure that _i_n_t_e_r_p->_r_e_s_u_l_t has its
default empty value when TTTTccccllll____TTTTiiiillllddddeeeeSSSSuuuubbbbsssstttt is invoked.
KKKKEEEEYYYYWWWWOOOORRRRDDDDSSSS
file name, home directory, tilde, user
PPPPaaaaggggeeee 2222